package hoodoos.flow;

import hoodoos.rule.api.Rule;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

@Setter
@Getter
@ToString
public class FlowRule {

  private String id;
  private String name;

  private FlowRuleTypeEnum type;
  private int maxExecuteTime;
  private boolean refuseThenContinue;
  /**
   * 这个对应的 Rule 的 name
   */
  private String ruleId;
  private Rule rule;

  public FlowRule() {
  }

  public FlowRule(String id, String name, FlowRuleTypeEnum type, int maxExecuteTime, boolean refuseThenContinue,
      String ruleId, Rule rule) {
    this.id = id;
    this.name = name;
    this.type = type;
    this.maxExecuteTime = maxExecuteTime;
    this.refuseThenContinue = refuseThenContinue;
    this.ruleId = ruleId;
    this.rule = rule;
  }

  public static FlowRule newStartFlowRule(String id) {
    FlowRule flowRule = new FlowRule();
    flowRule.setId(id);
    flowRule.setName("开始节点");
    flowRule.setType(FlowRuleTypeEnum.PROCESS_START);
    return flowRule;
  }

  public static FlowRule newEndFlowRule(String id) {
    FlowRule flowRule = new FlowRule();
    flowRule.setId(id);
    flowRule.setName("结束节点");
    flowRule.setType(FlowRuleTypeEnum.PROCESS_END);
    return flowRule;
  }
}
